#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define Maxsize 105

typedef struct StackRecord* Stack;
struct StackRecord {
    int Top;
    char* Array;
};

Stack creat() {
    Stack s = (Stack)malloc(sizeof(struct StackRecord));
    s->Array = (char*)malloc(Maxsize * sizeof(char));
    s->Top = -1;
    return s;
}

int is_empty(Stack s) {
    if (s->Top == -1) return 1;
    else return 0;
}
void push(Stack s, char x) {
    s->Array[++(s->Top)] = x;
}
void pop(Stack s) {
    s->Top--;

}
char top(Stack s) {
    return s->Array[s->Top];
}
char a[100];
char str[200];
int main() {
    int k = 0;
    char t;
    while (gets_s(str)) {

        if (str[0] == '.' && !str[1]) break;
        for (int i = 0; str[i]; i++) {
            if (str[i] == '(' || str[i] == '[' || str[i] == '{' || str[i] == ')' || str[i] == '}' || str[i] == ']')
                a[k++] = str[i];
            else if (str[i] == '/' && str[i + 1] == '*') {
                a[k++] = '<';
                i++;
            }
            else if (str[i] == '*' && str[i + 1] == '/') {
                a[k++] = '>';
                i++;
            }
        }
    }
    int flag = 0;
    Stack s = creat();
    for (int i = 0; i < k; i++) {
        if (a[i] == '(' || a[i] == '[' || a[i] == '{' || a[i] == '<') {
            push(s, a[i]);
        }
        else if (a[i] == ')') {
            if (s->Top != -1 && top(s) == '(') pop(s);
            else {
                t = a[i];
                flag = 1;
                break;
            }

        }
        else if (a[i] == ']') {
            if (s->Top != -1 && top(s) == '[') pop(s);
            else {
                t = a[i];
                flag = 1;
                break;
            }

        }
        else if (a[i] == '}') {
            if (s->Top != -1 && top(s) == '{') pop(s);
            else {
                t = a[i];
                flag = 1;
                break;
            }
        }
        else if (a[i] == '>') {
            if (s->Top != -1 && top(s) == '<') pop(s);
            else {
                t = a[i];
                flag = 1;
                break;
            }
        }
    }
    if (!flag && is_empty(s)) printf("YES\n");
    else {
        printf("NO\n");
        if (!is_empty(s)) {
            if (top(s) == '<') printf("/*-?\n");
            else printf("%c-?\n", top(s));
        }
        else {
            if (t == '>') printf("?-*/\n");
            else printf("?-%c\n", t);
        }
    }
    return 0;
}
